﻿CREATE TABLE [dbo].[DefinedDerivedAttributes] (
    [DerivedAttributesID]   INT            IDENTITY (1, 1) NOT NULL,
    [DerivedAttributesName] NVARCHAR (255) NOT NULL,
    [Description]           NVARCHAR (MAX) NULL,
    [EntityType]            NVARCHAR (100) NOT NULL,
    [EntitySubType]         NVARCHAR (100) NULL,
    [Format]                NVARCHAR (MAX) NOT NULL,
    [FilterEntityID]        INT            CONSTRAINT [DF_DefinedCombinedAttributes_EntityID] DEFAULT ((0)) NOT NULL,
    CONSTRAINT [PK_DefinedCombinedAttributes] PRIMARY KEY CLUSTERED ([DerivedAttributesID] ASC),
    CONSTRAINT [FK_DefinedCombinedAttributes_DefinedEntitySubTypes] FOREIGN KEY ([EntityType], [EntitySubType]) REFERENCES [dbo].[DefinedEntitySubTypes] ([EntityType], [EntitySubType]),
    CONSTRAINT [FK_DefinedCombinedAttributes_DefinedEntityTypes] FOREIGN KEY ([EntityType]) REFERENCES [dbo].[DefinedEntityTypes] ([EntityType]) ON UPDATE CASCADE,
    CONSTRAINT [FK_DefinedCombinedAttributes_Entity] FOREIGN KEY ([FilterEntityID]) REFERENCES [dbo].[Entities] ([EntityID])
);







